﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<title>jb-aptech毕业设计项目</TITLE>
	<meta name="renderer" content="ie-comp">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link href="../../css/style.css" rel="stylesheet" type="text/css">
	<link rel="stylesheet" href="../../css/menu.css">

	<script src="../../script/jquery-3.3.1.min.js"></script>
	<script src="../../script/common.js"></script>
	<script src="../../../js/bootstrap.min.js"></script>
	<script src="../../../js/vue.js"></script>
</head>
<body>
<div id="add">
	<div class="page_title">
		权限管理 > 权限管理 > 编辑权限
	</div>
	<div class="button_bar">
		<button class="common_button" onclick="help('');">
			帮助
		</button>
		<button class="common_button" onclick="back();">
			返回
		</button>
		<button class="common_button" @click="add()">
			保存
		</button>
	</div>
	<table class="query_form_table">
		<tr>
			<th>
				编号
			</th>
			<td>
				{{might.might_code}}
			</td>
			<th>
				权限类型
			</th>
			<td>
				<select v-model="might.might_icon" @change="aaa()">
					<option value="Folder">父节点
					<option value="Document">子节点
				</select>
			</td>
			<th>
				父节点</th>
			<td><select v-model="might.might_parent_code" id="code">
				<option value="">--请选择父节点--</option>
				<option v-for="t in typelist" :value="t.might_code">{{t.might_text}}</option>
			</select>
				<span id="codenull" style="display: none">ROOT_MENU</span>
			</td>
		</tr>
		<tr>
			<th>
				权限文本
			</th>
			<td>
				<input type="text" v-model="might.might_text">
				<span class="red_star" >*</span>
			</td>
			<th>
				权限URL
			</th>
			<td>
				<input type="text" v-model="might.might_url">
				<span class="red_star" >*</span>
			</td>
			<th>权限描述</th>
			<td>
				<textarea v-model="might.might_tip"></textarea>
			</td>
		</tr>
	</table>
</div>
</body>
<script>
	var cid;
    let id = sessionStorage.getItem("mid");
    var app = new Vue({
        el:'#add',
        data:{
            typelist:[],
            might:{
                might_code:'',
                might_icon:'',
                might_parent_code:'',
                might_text:'',
                might_url:'',
                might_tip:'',
            }
        },
        methods:{
            add(){
                if(this.might.might_text==""||null){
                    alert("必填项存在空值")
                    return;
                }
                if(this.might.might_url==""||null){
                    alert("必填项存在空值")
                    return;
                }
                $.getJSON("/updateSysMight",this.might,function (json) {
                    if(json.code==200){
                        alert("修改成功！！！！");
                        location='list.html';
                    }else{
                        alert("服务器异常！！！");
                    }
                });
            },
            aaa(){
                var codenull=document.getElementById("codenull");
                var code=document.getElementById("code");
                if(this.might.might_icon=='Folder'){
                    this.might.might_parent_code=0;
                    codenull.style.display='block';
                    code.style.display='none';
                }
                if(this.might.might_icon=='Document'){
                    this.might.might_parent_code=cid;
                    codenull.style.display='none';
                    code.style.display='block';
                }
            }
        },

        created(){
            $.getJSON("/querySysMightById/"+id,function (json) {
                app.might=json.data.obj;
                cid=app.might.might_parent_code;
            });
            $.getJSON("/querymighttype",function (json) {
                app.typelist=json.data.typelist;
                var codenull=document.getElementById("codenull");
                var code=document.getElementById("code");
                if(app.might.might_icon=='Folder'){
                    codenull.style.display='block';
                    code.style.display='none';
                }
                if(app.might.might_icon=='Document'){
                    codenull.style.display='none';
                    code.style.display='block';
                }
            });

        }
    })
</script>
</html>
